package com.fr.report.core.cal;

import com.fr.base.ArrayUtils;
import com.fr.base.ColumnRow;
import com.fr.base.FRContext;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.core.FT;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.TableData;
import com.fr.data.TableDataException;
import com.fr.data.core.DataUtils;
import com.fr.data.impl.DBTableData;
import com.fr.data.impl.LayerAdapter;
import com.fr.data.impl.LayerPageQueryAdapter;
import com.fr.data.impl.TableDataAdapter;
import com.fr.report.AbstractReport;
import com.fr.report.CellElement;
import com.fr.report.DefaultCellElement;
import com.fr.report.FloatElement;
import com.fr.report.Margin;
import com.fr.report.PageInfo;
import com.fr.report.PageSet;
import com.fr.report.PaperSetting;
import com.fr.report.PaperSize;
import com.fr.report.Report;
import com.fr.report.ReportPage;
import com.fr.report.ReportSettings;
import com.fr.report.TemplateReport;
import com.fr.report.WorkSheet;
import com.fr.report.cellElement.CellExpandAttr;
import com.fr.report.cellElement.CellPageAttr;
import com.fr.report.cellElement.Formula;
import com.fr.report.cellElement.Present;
import com.fr.report.cellElement.core.DSColumn;
import com.fr.report.core.ActiveReport;
import com.fr.report.core.DynamicValueList;
import com.fr.report.core.ReportHelper;
import com.fr.report.core.ReportUtils;
import com.fr.report.core.ScriptUtils;
import com.fr.report.core.SheetUtils;
import com.fr.report.highlight.Highlight;
import com.fr.report.highlight.HighlightGroup;
import com.fr.report.js.JavaScript;
import com.fr.report.js.NameJavaScript;
import com.fr.report.js.NameJavaScriptGroup;
import com.fr.report.parameter.Parameter;
import com.fr.report.script.AbstractNameSpace;
import com.fr.report.script.Calculator;
import com.fr.report.script.Function;
import com.fr.report.script.NameSpace;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FArray;
import com.fr.report.script.core.parser.CRAddress;
import com.fr.report.script.core.parser.ColumnRowLiteral;
import com.fr.report.script.core.parser.ColumnRowRange;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

public class LayerPageReport extends ActiveReport
{
  protected Map parameterMap;
  private int countPerPage = 30;

  public LayerPageReport(TemplateReport paramTemplateReport, Map paramMap, int paramInt)
  {
    super(paramTemplateReport);
    this.parameterMap = paramMap;
    this.countPerPage = Math.min(500, paramInt);
  }

  public void addCellElement(CellElement paramCellElement)
  {
    throw new UnsupportedOperationException();
  }

  public void addCellElement(CellElement paramCellElement, boolean paramBoolean)
  {
    throw new UnsupportedOperationException();
  }

  public void addFloatElement(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void bringFloatElementForward(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void bringFloatElementToFront(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator cellIterator()
  {
    throw new UnsupportedOperationException();
  }

  public Iterator floatIterator()
  {
    throw new UnsupportedOperationException();
  }

  public PageSet generateReportPageSet(PaperSetting paramPaperSetting)
  {
    return new LayerPageSet(this, paramPaperSetting, null);
  }

  public CellElement getCellElement(int paramInt1, int paramInt2)
  {
    throw new UnsupportedOperationException();
  }

  public Object getCellValue(int paramInt1, int paramInt2)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator getColumn(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public int getColumnCount()
  {
    throw new UnsupportedOperationException();
  }

  public FloatElement getFloatElement(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator getRow(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public int getRowCount()
  {
    throw new UnsupportedOperationException();
  }

  public void insertColumn(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public void insertRow(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public Iterator intersect(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    throw new UnsupportedOperationException();
  }

  public void merge(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    throw new UnsupportedOperationException();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    throw new UnsupportedOperationException();
  }

  public void removeAllCellElements()
  {
    throw new UnsupportedOperationException();
  }

  public void removeAllFloatElements()
  {
    throw new UnsupportedOperationException();
  }

  public boolean removeCellElement(CellElement paramCellElement)
  {
    throw new UnsupportedOperationException();
  }

  public CellElement removeCellElement(int paramInt1, int paramInt2)
  {
    throw new UnsupportedOperationException();
  }

  public void removeColumn(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public FloatElement removeFloatElement(String paramString)
  {
    throw new UnsupportedOperationException();
  }

  public boolean removeFloatElement(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void removeRow(int paramInt)
  {
    throw new UnsupportedOperationException();
  }

  public void sendFloatElementBackward(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void sendFloatElementToBack(FloatElement paramFloatElement)
  {
    throw new UnsupportedOperationException();
  }

  public void setCellValue(int paramInt1, int paramInt2, Object paramObject)
  {
    throw new UnsupportedOperationException();
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    throw new UnsupportedOperationException();
  }

  public void recalculate(Map paramMap)
  {
    throw new UnsupportedOperationException();
  }

  static TemplateReport access$100(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.packee;
  }

  static TemplateReport access$200(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.packee;
  }

  static TemplateReport access$300(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.packee;
  }

  static TemplateReport access$400(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.packee;
  }

  static TemplateReport access$600(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.packee;
  }

  static int access$800(LayerPageReport paramLayerPageReport)
  {
    return paramLayerPageReport.countPerPage;
  }

  private static class RelayExecuteError extends Error
  {
    private RelayExecuteError()
    {
    }

    RelayExecuteError(LayerPageReport.1 param1)
    {
    }
  }

  protected static class FamilyLayer
  {
    protected LayerSheetExecuter.LayerFamilyMember[] lfmArray;
    protected int top;
    protected int bottom;
    protected boolean expandable;

    private FamilyLayer(LayerSheetExecuter.LayerFamilyMember[] paramArrayOfLayerFamilyMember, int paramInt1, int paramInt2, boolean paramBoolean)
    {
      this.lfmArray = paramArrayOfLayerFamilyMember;
      this.top = paramInt1;
      this.bottom = paramInt2;
      this.expandable = paramBoolean;
    }

    FamilyLayer(LayerSheetExecuter.LayerFamilyMember[] paramArrayOfLayerFamilyMember, int paramInt1, int paramInt2, boolean paramBoolean, LayerPageReport.1 param1)
    {
      this(paramArrayOfLayerFamilyMember, paramInt1, paramInt2, paramBoolean);
    }
  }

  public class LayerPageSE extends LayerSheetExecuter
  {
    private int startRow;
    private int endRow;
    private int totalDataRow;
    private int curPageNumber;
    private Report dataReport;
    private int verticalTotalPageCount;
    protected List family_layer_list;
    private java.lang.Integer[] before_expand_ft_array;
    private java.lang.Integer[] after_expand_ft_array;
    private int start_repeat_head_page;
    private int start_repeat_foot_page;
    private LayerPageNameSpace lpns;
    private List unex_cell_list;
    private boolean perPage;
    private int paperPaintHeight;
    private final LayerPageReport this$0;

    protected LayerPageSE(, TemplateReport paramTemplateReport, Map paramMap, boolean paramBoolean, int paramInt)
    {
      super(paramTemplateReport, paramMap);
      this.this$0 = paramLayerPageReport;
      this.family_layer_list = new ArrayList();
      this.start_repeat_head_page = 2;
      this.start_repeat_foot_page = 2;
      this.unex_cell_list = null;
      this.perPage = true;
      this.perPage = paramBoolean;
      this.paperPaintHeight = paramInt;
      this.lpns = new LayerPageNameSpace(this, null, null);
      this.calculator.pushNameSpace(this.lpns);
      initPageInfo();
    }

    public void initPageInfo()
    {
      label153: int k;
      SynchronizedSEList.put(Thread.currentThread(), this);
      SheetUtils.calculateDefaultParent(this.report);
      buildGenealogy();
      check_layer();
      int i = 0;
      ArrayList localArrayList1 = new ArrayList();
      ArrayList localArrayList2 = new ArrayList();
      for (int j = 0; j < this.family_layer_list.size(); ++j)
      {
        LayerPageReport.FamilyLayer localFamilyLayer = (LayerPageReport.FamilyLayer)this.family_layer_list.get(j);
        if (!(localFamilyLayer.expandable))
        {
          if (i == 0)
          {
            l = 0;
            while (true)
            {
              if (l >= localFamilyLayer.lfmArray.length)
                break label153;
              dealwith_pageinfo(localFamilyLayer.lfmArray[l], localArrayList1);
              ++l;
            }
          }
          int l = 0;
          while (true)
          {
            if (l >= localFamilyLayer.lfmArray.length)
              break label153;
            dealwith_pageinfo(localFamilyLayer.lfmArray[l], localArrayList2);
            ++l;
          }
        }
        i = 1;
      }
      LayerPageReport.1 local1 = new LayerPageReport.1(this);
      this.before_expand_ft_array = ((java.lang.Integer[])localArrayList1.toArray(new java.lang.Integer[0]));
      this.after_expand_ft_array = ((java.lang.Integer[])localArrayList2.toArray(new java.lang.Integer[0]));
      Arrays.sort(this.before_expand_ft_array, local1);
      Arrays.sort(this.after_expand_ft_array, local1);
      if (this.repeat_page_head_rows != null)
        for (k = 0; k < this.before_expand_ft_array.length; ++k)
        {
          this.start_repeat_head_page = (k + 2);
          if (this.before_expand_ft_array[k].intValue() >= this.repeat_page_head_rows.getTo() - 1)
            break;
          if (this.before_expand_ft_array[k].intValue() >= this.repeat_page_head_rows.getFrom())
            break;
        }
      if (this.repeat_page_foot_rows != null)
        for (k = this.after_expand_ft_array.length - 1; k >= 0; --k)
        {
          this.start_repeat_foot_page = (this.after_expand_ft_array.length - k + 2);
          if (this.after_expand_ft_array[k].intValue() + 1 <= this.repeat_page_foot_rows.getFrom())
            break;
          if (this.after_expand_ft_array[k].intValue() + 1 <= this.repeat_page_foot_rows.getTo() - 1)
            break;
        }
      try
      {
        if (this.data != null)
          this.totalDataRow = this.data.getRowCount();
      }
      catch (TableDataException localTableDataException)
      {
        FRContext.getLogger().log(Level.WARNING, localTableDataException.getMessage(), localTableDataException);
      }
      this.verticalTotalPageCount = (this.before_expand_ft_array.length + ((this.totalDataRow == 0) ? 0 : (this.totalDataRow - 1) / LayerPageReport.access$800(this.this$0) + 1) + this.after_expand_ft_array.length);
      if (this.verticalTotalPageCount == 0)
        this.verticalTotalPageCount = 1;
      SynchronizedSEList.removeSheetExecuter(Thread.currentThread());
    }

    private void dealwith_pageinfo(, List paramList)
    {
      int i;
      if (paramLayerFamilyMember.sons != null)
        for (i = 0; i < paramLayerFamilyMember.sons.size(); ++i)
          dealwith_pageinfo((LayerSheetExecuter.LayerFamilyMember)paramLayerFamilyMember.sons.get(i), paramList);
      if (paramLayerFamilyMember.current.getCellPageAttr() != null)
      {
        java.lang.Integer localInteger;
        if (paramLayerFamilyMember.current.getCellPageAttr().isPageBeforeRow())
        {
          localInteger = new java.lang.Integer(paramLayerFamilyMember.current.getRow() - 1);
          if (!(paramList.contains(localInteger)))
            paramList.add(localInteger);
        }
        else if (paramLayerFamilyMember.current.getCellPageAttr().isPageAfterRow())
        {
          localInteger = new java.lang.Integer(paramLayerFamilyMember.current.getRow() + paramLayerFamilyMember.current.getRowSpan() - 1);
          if (!(paramList.contains(localInteger)))
            paramList.add(localInteger);
        }
      }
    }

    public Report execute(, boolean paramBoolean)
    {
      double d;
      int l;
      if ((paramInt < 1) || (paramInt > this.verticalTotalPageCount))
        return null;
      SynchronizedSEList.put(Thread.currentThread(), this);
      LayerPageNameSpace.access$900(this.lpns);
      this.unex_cell_list = new ArrayList();
      this.curPageNumber = paramInt;
      if (this.curPageNumber <= this.before_expand_ft_array.length)
      {
        this.startRow = 0;
        this.endRow = 0;
      }
      else if (this.curPageNumber <= this.verticalTotalPageCount - this.after_expand_ft_array.length)
      {
        this.startRow = ((this.curPageNumber - this.before_expand_ft_array.length - 1) * LayerPageReport.access$800(this.this$0));
        this.endRow = (this.startRow + LayerPageReport.access$800(this.this$0) - 1);
        this.endRow = Math.min(this.endRow, this.totalDataRow - 1);
      }
      else
      {
        this.startRow = 0;
        this.endRow = 0;
      }
      this.dataReport = createInitReport();
      ex_fill(this.data, paramBoolean);
      SynchronizedSEList.removeSheetExecuter(Thread.currentThread());
      if (this.curPageNumber > this.verticalTotalPageCount)
        return null;
      int i = 0;
      for (int j = 0; j < this.dataReport.getRowCount(); ++j)
        i += this.dataReport.getRowHeight(j);
      if (i > this.paperPaintHeight)
      {
        d = this.paperPaintHeight / i;
        for (l = 0; l < this.dataReport.getRowCount(); ++l)
          this.dataReport.setRowHeight(l, (int)(this.dataReport.getRowHeight(l) * d));
      }
      LayerPageNameSpace.access$1002(this.lpns, -2);
      for (int k = 0; k < this.unex_cell_list.size(); ++k)
      {
        CellElement localCellElement = (CellElement)this.unex_cell_list.get(k);
        localCellElement.setValue(resolveUnExpandCellELmentValue(localCellElement.getValue()));
      }
      this.unex_cell_list.clear();
      this.unex_cell_list = null;
      return this.dataReport;
    }

    private Report createInitReport()
    {
      Object localObject;
      try
      {
        localObject = (Report)((AbstractReport)this.report).deriveClearReportWithReadOnlyAttr();
      }
      catch (CloneNotSupportedException localCloneNotSupportedException)
      {
        FRContext.getLogger().log(Level.WARNING, localCloneNotSupportedException.getMessage(), localCloneNotSupportedException);
        localObject = new WorkSheet();
      }
      for (int i = 0; i < this.report.getColumnCount(); ++i)
        ((Report)localObject).setColumnWidth(i, this.report.getColumnWidth(i));
      return ((Report)localObject);
    }

    public int getDataStartRow()
    {
      return this.startRow;
    }

    public int getDataPageSize()
    {
      return LayerPageReport.access$800(this.this$0);
    }

    public int getCurPageNumber()
    {
      return this.curPageNumber;
    }

    private int ex_fill(, boolean paramBoolean)
    {
      int k;
      int i = 0;
      if ((paramBoolean) && (this.repeat_page_head_rows != null) && (this.curPageNumber >= this.start_repeat_head_page))
        i += dealwithRepeatHeadRows();
      Object localObject = null;
      for (int j = 0; j < this.family_layer_list.size(); ++j)
      {
        LayerPageReport.FamilyLayer localFamilyLayer = (LayerPageReport.FamilyLayer)this.family_layer_list.get(j);
        if (localFamilyLayer.expandable)
          localObject = localFamilyLayer;
      }
      if (this.curPageNumber <= this.before_expand_ft_array.length + 1)
      {
        j = (this.curPageNumber != 1) ? this.before_expand_ft_array[(this.curPageNumber - 2)].intValue() + 1 : 0;
        k = (localObject != null) ? localObject.top - 1 : (this.curPageNumber != this.before_expand_ft_array.length + 1) ? this.before_expand_ft_array[(this.curPageNumber - 1)].intValue() : this.report.getRowCount();
        if ((this.repeat_page_head_rows != null) && (this.curPageNumber >= this.start_repeat_head_page) && (this.repeat_page_head_rows.getTo() - 1 <= j))
          i += ex_unexpand_rect(this.repeat_page_head_rows.getTo(), k, i);
        else
          i += ex_unexpand_rect(j, k, i);
      }
      if (localObject != null)
      {
        if ((this.curPageNumber > this.before_expand_ft_array.length) && (this.curPageNumber <= this.verticalTotalPageCount - this.after_expand_ft_array.length))
          i += ex_expand_rect(localObject.lfmArray, i, localObject.top, localObject.bottom, paramTableData);
        if ((this.curPageNumber <= this.verticalTotalPageCount) && (this.curPageNumber >= this.verticalTotalPageCount - this.after_expand_ft_array.length))
        {
          j = this.after_expand_ft_array.length - this.verticalTotalPageCount + this.curPageNumber;
          k = (this.curPageNumber != this.verticalTotalPageCount - this.after_expand_ft_array.length) ? this.after_expand_ft_array[(j - 1)].intValue() + 1 : localObject.bottom + 1;
          int l = (this.curPageNumber != this.verticalTotalPageCount) ? this.after_expand_ft_array[j].intValue() : this.report.getRowCount();
          if ((this.repeat_page_foot_rows != null) && (this.verticalTotalPageCount - this.curPageNumber >= this.start_repeat_foot_page - 1) && (this.repeat_page_foot_rows.getFrom() >= l))
            i += ex_unexpand_rect(k, this.repeat_page_foot_rows.getFrom() - 1, i);
          else
            i += ex_unexpand_rect(k, l, i);
        }
      }
      if ((paramBoolean) && (this.repeat_page_foot_rows != null) && (this.verticalTotalPageCount - this.curPageNumber >= this.start_repeat_foot_page - 1))
        i += ex_unexpand_rect(this.repeat_page_foot_rows.getFrom(), this.repeat_page_foot_rows.getTo() - 1, i);
      return i;
    }

    private int dealwithRepeatHeadRows()
    {
      return ex_unexpand_rect(this.repeat_page_head_rows.getFrom(), this.repeat_page_head_rows.getTo() - 1, 0);
    }

    private void check_layer()
    {
      ArrayList localArrayList = new ArrayList();
      dealwith_layer(localArrayList);
      try
      {
        if (this.data != null)
          this.data = ((TableData)this.data.clone());
      }
      catch (CloneNotSupportedException localCloneNotSupportedException)
      {
        FRContext.getLogger().log(Level.WARNING, localCloneNotSupportedException.getMessage(), localCloneNotSupportedException);
      }
      ex_FamilyMemberArray((LayerSheetExecuter.LayerFamilyMember[])localArrayList.toArray(new LayerSheetExecuter.LayerFamilyMember[localArrayList.size()]));
    }

    protected void ex_FamilyMemberArray()
    {
      sort_FamilyMemberArray(paramArrayOfLayerFamilyMember);
      boolean bool1 = false;
      int i = 0;
      while (i < paramArrayOfLayerFamilyMember.length)
      {
        ArrayList localArrayList = new ArrayList();
        LayerSheetExecuter.LayerFamilyMember localLayerFamilyMember1 = paramArrayOfLayerFamilyMember[i];
        int j = localLayerFamilyMember1.rect.bottom;
        for (LayerSheetExecuter.LayerFamilyMember localLayerFamilyMember2 = localLayerFamilyMember1; localLayerFamilyMember2.rect.top <= j; localLayerFamilyMember2 = paramArrayOfLayerFamilyMember[i])
        {
          j = Math.max(j, localLayerFamilyMember2.rect.bottom);
          localArrayList.add(localLayerFamilyMember2);
          if (++i >= paramArrayOfLayerFamilyMember.length)
            break;
        }
        boolean bool2 = false;
        if (!(bool1))
          if ((bool1 = isExpandableRect((LayerSheetExecuter.LayerFamilyMember[])localArrayList.toArray(new LayerSheetExecuter.LayerFamilyMember[0]))))
            bool2 = true;
          else
            bool2 = false;
        else
          bool2 = false;
        FRContext.getLogger().log(Level.INFO, ((bool2) ? "ExpandableRect" : "UnExpandableRect") + " Area:row " + (localLayerFamilyMember1.rect.top + 1) + "-" + (j + 1));
        this.family_layer_list.add(new LayerPageReport.FamilyLayer((LayerSheetExecuter.LayerFamilyMember[])localArrayList.toArray(new LayerSheetExecuter.LayerFamilyMember[0]), localLayerFamilyMember1.rect.top, j, bool2, null));
      }
    }

    private boolean isExpandableRect()
    {
      for (int i = 0; i < paramArrayOfLayerFamilyMember.length; ++i)
        if (isExpandableRect(paramArrayOfLayerFamilyMember[i]))
          return true;
      return false;
    }

    protected boolean isExpandableRect()
    {
      if ((paramLayerFamilyMember.current.getCellExpandAttr() == null) || (paramLayerFamilyMember.current.getCellExpandAttr().getDirection() != 0) || ((paramLayerFamilyMember.current.getCellExpandAttr().getExtendable() != 0) && (paramLayerFamilyMember.current.getCellExpandAttr().getExtendable() != 1)))
        return false;
      if (paramLayerFamilyMember.current.getValue() instanceof DSColumn)
        return true;
      Object localObject = null;
      if (!((localObject = paramLayerFamilyMember.current.getValue()) instanceof Formula))
        return false;
      String str = ((Formula)localObject).getContent();
      try
      {
        localObject = this.calculator.eval(str.substring(1));
        if (localObject instanceof FArray)
        {
          this.totalDataRow = ((FArray)localObject).length();
          return true;
        }
      }
      catch (Exception localException)
      {
        FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
      }
      return false;
    }

    private int ex_unexpand_rect(, int paramInt2, int paramInt3)
    {
      Object localObject;
      if (LayerPageNameSpace.access$1000(this.lpns) >= 0)
        LayerPageNameSpace.access$1002(this.lpns, -2);
      for (int i = 0; i <= paramInt2; ++i)
      {
        if (i >= paramInt1)
          this.dataReport.setRowHeight(paramInt3 + i - paramInt1, this.report.getRowHeight(i));
        Iterator localIterator = this.report.getRow(i);
        while (true)
        {
          while (true)
          {
            if (!(localIterator.hasNext()))
              break label295;
            localObject = (CellElement)localIterator.next();
            if (((CellElement)localObject).getRow() + ((CellElement)localObject).getRowSpan() - 1 >= paramInt1)
              break;
          }
          int k = (((CellElement)localObject).getRow() < paramInt1) ? paramInt1 : ((CellElement)localObject).getRow();
          int l = (((CellElement)localObject).getRow() < paramInt1) ? ((CellElement)localObject).getRow() + ((CellElement)localObject).getRowSpan() - k : ((CellElement)localObject).getRowSpan();
          l = (k + l - 1 > paramInt2) ? paramInt2 - k + 1 : l;
          CellElement localCellElement2 = createNewCellElement((CellElement)localObject, ((CellElement)localObject).getColumn(), k - paramInt1 + paramInt3, ((CellElement)localObject).getColumnSpan(), l, ((CellElement)localObject).getValue());
          try
          {
            localCellElement2.setValue(resolveUnExpandCellELmentValue(((CellElement)localObject).getValue()));
          }
          catch (LayerPageReport.RelayExecuteError localRelayExecuteError)
          {
            this.unex_cell_list.add(localCellElement2);
          }
          this.dataReport.addCellElement(localCellElement2);
        }
      }
      label295: i = paramInt2 - paramInt1 + 1;
      for (int j = 0; j < i; ++j)
      {
        localObject = this.dataReport.getRow(j + paramInt3);
        while (((Iterator)localObject).hasNext())
        {
          CellElement localCellElement1 = (CellElement)((Iterator)localObject).next();
          dealwith_highlight(localCellElement1, this.dataReport);
          dealwith_hyperlink(localCellElement1, this.dataReport);
          dealwith_present(localCellElement1);
          dealwith_row_height(localCellElement1, this.dataReport);
        }
      }
      return i;
    }

    private int ex_expand_rect(, int paramInt1, int paramInt2, int paramInt3, TableData paramTableData)
    {
      int i = 0;
      for (int j = 0; j <= this.endRow - this.startRow; ++j)
      {
        Object localObject;
        try
        {
          if ((this.data != null) && (!(this.data.hasRow(this.startRow + j))))
            break label287:
        }
        catch (TableDataException localTableDataException)
        {
          FRContext.getLogger().log(Level.WARNING, localTableDataException.getMessage(), localTableDataException);
          break label287:
        }
        i = j * (paramInt3 - paramInt2 + 1) + paramInt1;
        for (int k = paramInt2; k <= paramInt3; ++k)
          this.dataReport.setRowHeight(k - paramInt2 + i, this.report.getRowHeight(k));
        LayerPageNameSpace.access$1002(this.lpns, this.startRow + j);
        for (int l = 0; l < paramArrayOfLayerFamilyMember.length; ++l)
        {
          localObject = paramArrayOfLayerFamilyMember[l];
          ex_expand_lfm((LayerSheetExecuter.LayerFamilyMember)localObject, paramInt2, paramInt3 - paramInt2 + 1, j, i, paramTableData, true);
        }
        for (l = paramInt2; l <= paramInt3; ++l)
        {
          localObject = this.dataReport.getRow(l - paramInt2 + i);
          while (((Iterator)localObject).hasNext())
          {
            CellElement localCellElement = (CellElement)((Iterator)localObject).next();
            dealwith_highlight(localCellElement, this.dataReport);
            dealwith_hyperlink(localCellElement, this.dataReport);
            dealwith_present(localCellElement);
            dealwith_row_height(localCellElement, this.dataReport);
          }
        }
      }
      label287: return (j * (paramInt3 - paramInt2 + 1));
    }

    private void ex_expand_lfm(, int paramInt1, int paramInt2, int paramInt3, int paramInt4, TableData paramTableData, boolean paramBoolean)
    {
      int i;
      ColumnRow localColumnRow = ColumnRow.valueOf(paramLayerFamilyMember.current.getColumn(), paramInt4 + paramLayerFamilyMember.current.getRow() - paramInt1);
      Object localObject = resolveExpandCellElementValue(paramLayerFamilyMember, paramTableData, LayerPageNameSpace.access$1000(this.lpns), this.calculator);
      CellElement localCellElement = (CellElement)LayerPageNameSpace.access$1200(this.lpns).get(paramLayerFamilyMember.current_cr);
      if ((paramInt3 != 0) && (paramBoolean) && (paramLayerFamilyMember.isGroup) && (paramLayerFamilyMember.current.getRowSpan() == paramInt2) && (localCellElement != null) && (localObject != Primitive.NULL) && (ComparatorUtils.equals(localObject, localCellElement.getValue())))
      {
        localCellElement.setRowSpan(localCellElement.getRowSpan() + paramInt2);
        localCellElement = null;
      }
      else
      {
        localCellElement = createNewCellElement(paramLayerFamilyMember.current, localColumnRow.getColumn(), localColumnRow.getRow(), paramLayerFamilyMember.current.getColumnSpan(), paramLayerFamilyMember.current.getRowSpan(), localObject);
        this.dataReport.addCellElement(localCellElement);
        LayerPageNameSpace.access$1200(this.lpns).put(paramLayerFamilyMember.current_cr, localCellElement);
      }
      if (paramLayerFamilyMember.sons != null)
        for (i = 0; i < paramLayerFamilyMember.sons.size(); ++i)
          ex_expand_lfm((LayerSheetExecuter.LayerFamilyMember)paramLayerFamilyMember.sons.get(i), paramInt1, paramInt2, paramInt3, paramInt4, paramTableData, localCellElement == null);
    }

    private CellElement createNewCellElement(, int paramInt1, int paramInt2, int paramInt3, int paramInt4, Object paramObject)
    {
      DefaultCellElement localDefaultCellElement = new DefaultCellElement(paramInt1, paramInt2, paramInt3, paramInt4, paramObject);
      localDefaultCellElement.setStyle(paramCellElement.getStyle());
      localDefaultCellElement.setCellExpandAttr(paramCellElement.getCellExpandAttr());
      localDefaultCellElement.setCellGUIAttr(paramCellElement.getCellGUIAttr());
      localDefaultCellElement.setCellPageAttr(paramCellElement.getCellPageAttr());
      localDefaultCellElement.setHighlightGroup(paramCellElement.getHighlightGroup());
      try
      {
        localDefaultCellElement.setNameHyperlinkGroup((paramCellElement.getNameHyperlinkGroup() == null) ? null : (NameJavaScriptGroup)paramCellElement.getNameHyperlinkGroup().clone());
      }
      catch (CloneNotSupportedException localCloneNotSupportedException)
      {
      }
      localDefaultCellElement.setPresent(paramCellElement.getPresent());
      return localDefaultCellElement;
    }

    private Object resolveUnExpandCellELmentValue()
    {
      if (paramObject instanceof Formula)
      {
        String str = ((Formula)paramObject).getContent();
        try
        {
          paramObject = this.calculator.eval(str.substring(1));
        }
        catch (Exception localException)
        {
          FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
        }
      }
      else if (paramObject instanceof DSColumn)
      {
        paramObject = null;
      }
      return paramObject;
    }

    private Object resolveExpandCellElementValue(, TableData paramTableData, int paramInt, Calculator paramCalculator)
    {
      Object localObject = paramLayerFamilyMember.current.getValue();
      if (localObject instanceof DSColumn)
      {
        localObject = getTableDataValue(paramTableData, paramInt, paramLayerFamilyMember.getColumnIndex(paramTableData));
      }
      else if (localObject instanceof Formula)
      {
        String str = ((Formula)localObject).getContent();
        try
        {
          localObject = paramCalculator.eval(str.substring(1));
        }
        catch (Exception localException)
        {
          FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
        }
        if (localObject instanceof FArray)
          if (((FArray)localObject).length() > paramInt)
            localObject = ((FArray)localObject).elementAt(paramInt);
          else
            localObject = Primitive.NULL;
      }
      LayerPageNameSpace.access$1300(this.lpns, paramLayerFamilyMember.current_cr, localObject);
      return localObject;
    }

    private void dealwith_hyperlink(, Report paramReport)
    {
      if (paramCellElement == null)
        return;
      if (paramCellElement.getNameHyperlinkGroup() != null)
      {
        Report localReport = this.calculator.getCurrentReport();
        this.calculator.setCurrentReport(paramReport);
        this.calculator.setCurrentColumnRow(ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow()));
        NameJavaScriptGroup localNameJavaScriptGroup = paramCellElement.getNameHyperlinkGroup();
        for (int i = 0; i < localNameJavaScriptGroup.size(); ++i)
        {
          int j;
          JavaScript localJavaScript = localNameJavaScriptGroup.getNameHyperlink(i).getJavaScript();
          Parameter[] arrayOfParameter = localJavaScript.getParameters();
          if (!(ArrayUtils.isEmpty(arrayOfParameter)))
            for (j = 0; j < arrayOfParameter.length; ++j)
            {
              Parameter localParameter = arrayOfParameter[j];
              Object localObject = localParameter.getValue();
              if (localObject instanceof Formula)
              {
                Formula localFormula = (Formula)localObject;
                localFormula.setResult(ScriptUtils.executeFormula(this.calculator, localFormula, ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow())));
              }
            }
        }
        this.calculator.setCurrentReport(localReport);
      }
    }

    private void dealwith_highlight(, Report paramReport)
    {
      if ((paramCellElement == null) || (paramReport == null))
        return;
      HighlightGroup localHighlightGroup = paramCellElement.getHighlightGroup();
      if (localHighlightGroup != null)
      {
        Report localReport = this.calculator.getCurrentReport();
        this.calculator.setCurrentReport(paramReport);
        this.calculator.setCurrentColumnRow(ColumnRow.valueOf(paramCellElement.getColumn(), paramCellElement.getRow()));
        for (int i = 0; i < localHighlightGroup.size(); ++i)
        {
          Highlight localHighlight = localHighlightGroup.getHighlight(i);
          if (localHighlight.eval(paramCellElement, this.calculator))
            localHighlight.action(paramCellElement, this.calculator);
        }
        paramCellElement.setHighlightGroup(null);
        this.calculator.setCurrentReport(localReport);
      }
    }

    private void dealwith_present()
    {
      if (paramCellElement.getPresent() != null)
      {
        paramCellElement.setValue(paramCellElement.getPresent().present(paramCellElement.getValue(), this.calculator));
        paramCellElement.setPresent(null);
      }
    }

    private Object getTableDataValue(, int paramInt1, int paramInt2)
    {
      return DataUtils.getTableDataValue(paramTableData, paramInt1, paramInt2);
    }

    public TableDataAdapter createDBTableDataAdapter(, String paramString)
    {
      if (paramDBTableData == null)
        return null;
      if ((this.data != null) && (this.data == paramDBTableData))
      {
        if (this.perPage)
          return new LayerPageQueryAdapter(paramDBTableData.getDatabase(), paramString, paramDBTableData.getPageQuerySql(), paramDBTableData.getParameters(), getDataPageSize());
        return new LayerAdapter(paramDBTableData.getDatabase(), paramString);
      }
      return super.createDBTableDataAdapter(paramDBTableData, paramString);
    }

    protected void release()
    {
      if (this.calculator != null)
        this.calculator.release();
      if (this.lpns != null)
        this.lpns.release();
      releaseTableData(this.report);
      try
      {
        if (this.data != null)
          this.data.release();
      }
      catch (Exception localException)
      {
        FRContext.getLogger().log(Level.WARNING, localException.getMessage(), localException);
      }
      SynchronizedSEList.removeSheetExecuter(Thread.currentThread());
    }

    static int access$500(LayerPageSE paramLayerPageSE)
    {
      return paramLayerPageSE.verticalTotalPageCount;
    }

    static int access$1500(LayerPageSE paramLayerPageSE)
    {
      return paramLayerPageSE.startRow;
    }

    static int access$1600(LayerPageSE paramLayerPageSE)
    {
      return paramLayerPageSE.totalDataRow;
    }

    private class LayerPageNameSpace extends AbstractNameSpace
    {
      private NameSpace parent;
      private Map crMap;
      private Map lcMap;
      private int rowIndex;
      private final LayerPageReport.LayerPageSE this$1;

      private LayerPageNameSpace(, NameSpace paramNameSpace)
      {
        this.this$1 = paramLayerPageSE;
        this.rowIndex = -1;
        this.parent = paramNameSpace;
        this.crMap = new HashMap();
        this.lcMap = new HashMap();
      }

      private void reInit()
      {
        this.rowIndex = -1;
        this.crMap.clear();
        this.lcMap.clear();
      }

      private void putCrValue(, Object paramObject)
      {
        FArray localFArray = (FArray)this.crMap.get(paramColumnRow);
        if (localFArray == null)
        {
          localFArray = new FArray();
          this.crMap.put(paramColumnRow, localFArray);
        }
        localFArray.add(paramObject);
      }

      private Object getCurrentCrValue()
      {
        if (this.rowIndex == -1)
          throw new LayerPageReport.RelayExecuteError(null);
        FArray localFArray = (FArray)this.crMap.get(paramColumnRow);
        if ((localFArray == null) || (localFArray.length() == 0))
          return null;
        if (this.rowIndex - LayerPageReport.LayerPageSE.access$1500(this.this$1) >= 0)
        {
          if (localFArray.length() > this.rowIndex - LayerPageReport.LayerPageSE.access$1500(this.this$1))
            return localFArray.elementAt(this.rowIndex - LayerPageReport.LayerPageSE.access$1500(this.this$1));
          return null;
        }
        return localFArray;
      }

      public Function getMethod(, Calculator paramCalculator)
      {
        Function localFunction = (this.parent == null) ? null : this.parent.getMethod(paramObject, paramCalculator);
        return ((localFunction == null) ? super.getMethod(paramObject, paramCalculator) : localFunction);
      }

      public Object getCellElementAttribute(, Object paramObject, Calculator paramCalculator)
      {
        return null;
      }

      public Object getVariable(, Calculator paramCalculator)
      {
        Object localObject = null;
        if (this.parent != null)
          localObject = this.parent.getVariable(paramObject, paramCalculator);
        if (localObject != null)
          return localObject;
        if ((paramObject instanceof String) && ("$$fr_totalRowCount".equalsIgnoreCase((String)paramObject)))
          return new java.lang.Integer(LayerPageReport.LayerPageSE.access$1600(this.this$1));
        if (paramObject instanceof ColumnRowRange)
          if (((ColumnRowRange)paramObject).getTo() == null)
          {
            ColumnRowLiteral localColumnRowLiteral = ((ColumnRowRange)paramObject).getFrom();
            paramObject = (localColumnRowLiteral == null) ? null : localColumnRowLiteral.getTargetColumnRow();
          }
        else if (paramObject instanceof CRAddress)
          localObject = new java.lang.Integer(this.rowIndex + 1);
        if (paramObject instanceof ColumnRow)
          localObject = getCurrentCrValue((ColumnRow)paramObject);
        if (localObject != null)
          return localObject;
        return null;
      }

      protected void release()
      {
        if (this.crMap != null)
          this.crMap.clear();
        if (this.lcMap != null)
          this.lcMap.clear();
      }

      LayerPageNameSpace(, NameSpace paramNameSpace, LayerPageReport.1 param1)
      {
        this(paramLayerPageSE, paramNameSpace);
      }

      static void access$900(LayerPageNameSpace paramLayerPageNameSpace)
      {
        paramLayerPageNameSpace.reInit();
      }

      static int access$1002(LayerPageNameSpace paramLayerPageNameSpace)
      {
        return (paramLayerPageNameSpace.rowIndex = paramInt);
      }

      static int access$1000(LayerPageNameSpace paramLayerPageNameSpace)
      {
        return paramLayerPageNameSpace.rowIndex;
      }

      static Map access$1200(LayerPageNameSpace paramLayerPageNameSpace)
      {
        return paramLayerPageNameSpace.lcMap;
      }

      static void access$1300(LayerPageNameSpace paramLayerPageNameSpace, Object paramObject)
      {
        paramLayerPageNameSpace.putCrValue(paramColumnRow, paramObject);
      }
    }
  }

  private class LayerExportPageSet extends LayerPageReport.LayerPageSet
  {
    private int last_page_index;
    private final LayerPageReport this$0;

    LayerExportPageSet(, PaperSetting paramPaperSetting, boolean paramBoolean)
    {
      super(paramLayerPageReport, paramPaperSetting, null);
      this.this$0 = paramLayerPageReport;
      this.last_page_index = -1;
      this.isPage = paramBoolean;
    }

    protected boolean isPageQuery()
    {
      return false;
    }

    public ReportPage getPage()
    {
      if (paramInt < 0)
        return null;
      if (paramInt < this.last_page_index)
      {
        reInit();
        this.last_page_index = -1;
        return getPage(paramInt);
      }
      this.last_page_index = paramInt;
      return super.getPage(paramInt);
    }

    public PageSet getTraversingCase()
    {
      return this;
    }

    public void release()
    {
      if (this.se != null)
      {
        this.se.release();
        this.se = null;
      }
    }
  }

  public class LayerPageSet extends PageSet
  {
    private PageInfo pageInfo;
    private int last_row_index;
    private Report pageReport;
    protected LayerPageReport.LayerPageSE se;
    protected boolean isPage;
    private List case4traversingList;
    private PaperSetting paperSetting;
    private List page_column_index_ft_list;
    private int paperPaintHeight;
    private final LayerPageReport this$0;

    private LayerPageSet(, PaperSetting paramPaperSetting)
    {
      this.this$0 = paramLayerPageReport;
      this.last_row_index = -1;
      this.pageReport = null;
      this.se = null;
      this.isPage = true;
      this.case4traversingList = new ArrayList(2);
      this.page_column_index_ft_list = new ArrayList();
      this.paperSetting = paramPaperSetting;
    }

    private void initPageInfo()
    {
      int i;
      ReportSettings localReportSettings = ReportUtils.getReportSettings(LayerPageReport.access$100(this.this$0));
      if (this.paperSetting == null)
      {
        i = 2147483647;
        this.paperPaintHeight = 2147483647;
      }
      else
      {
        localObject = this.paperSetting.getPaperSize();
        Margin localMargin = this.paperSetting.getMargin();
        double d1 = ((PaperSize)localObject).getWidth();
        double d2 = ((PaperSize)localObject).getHeight();
        if (this.paperSetting.getOrientation() == 1)
        {
          d1 = ((PaperSize)localObject).getHeight();
          d2 = ((PaperSize)localObject).getWidth();
        }
        i = (int)((d1 - localMargin.getLeft() - localMargin.getRight()) * 96.0D);
        this.paperPaintHeight = (int)((d2 - localMargin.getTop() - localMargin.getBottom() - localReportSettings.getHeaderHeight() - localReportSettings.getFooterHeight()) * 96.0D);
      }
      Object localObject = ReportHelper.getColumnWidthList(LayerPageReport.access$200(this.this$0));
      int j = 0;
      FT localFT = new FT(0, 1);
      this.page_column_index_ft_list.add(localFT);
      int k = 0;
      int l = LayerPageReport.access$300(this.this$0).getColumnCount();
      while (k < l)
      {
        j += ((DynamicValueList)localObject).get(k);
        if (j > i)
        {
          localFT = new FT(k, k + 1);
          this.page_column_index_ft_list.add(localFT);
          j = ((DynamicValueList)localObject).get(k);
        }
        else
        {
          localFT.setTo(k + 1);
        }
        ++k;
      }
      this.se = new LayerPageReport.LayerPageSE(this.this$0, LayerPageReport.access$400(this.this$0), this.this$0.parameterMap, isPageQuery(), this.paperPaintHeight);
      this.pageInfo = new PageInfo(LayerPageReport.LayerPageSE.access$500(this.se) * this.page_column_index_ft_list.size());
    }

    protected boolean isPageQuery()
    {
      return true;
    }

    public ReportPage getPage()
    {
      int i = paramInt + 1;
      if (this.se == null)
        initPageInfo();
      if (!(hasPage(i)))
        return null;
      int j = (i - 1) / this.page_column_index_ft_list.size();
      if (j != this.last_row_index)
        createPageReport(j + 1);
      this.last_row_index = j;
      if (this.pageReport == null)
        return null;
      int k = (i - 1) % this.page_column_index_ft_list.size();
      ReportPage localReportPage = new ReportPage(this.pageReport, new PageInfo(this.pageInfo.getTotalPages()), this.paperSetting, new FT[] { new FT(0, this.pageReport.getRowCount()) }, new FT[] { (FT)this.page_column_index_ft_list.get(k) }, k + 1, this.last_row_index + 1);
      localReportPage.setCurrentPageNumber(i);
      return localReportPage;
    }

    public boolean sizePredictable()
    {
      return true;
    }

    public int size()
    {
      if (this.se == null)
        initPageInfo();
      return this.pageInfo.getTotalPages();
    }

    public boolean pageCached()
    {
      return false;
    }

    public PageSet getTraversingCase()
    {
      return getTraversingCase(true);
    }

    public PageSet getTraversingCase()
    {
      LayerPageReport.LayerExportPageSet localLayerExportPageSet = new LayerPageReport.LayerExportPageSet(this.this$0, this.paperSetting, paramBoolean);
      this.case4traversingList.add(localLayerExportPageSet);
      return localLayerExportPageSet;
    }

    private boolean hasPage()
    {
      return ((paramInt >= 1) && (paramInt <= this.pageInfo.getTotalPages()));
    }

    protected void reInit()
    {
      release();
      this.se = new LayerPageReport.LayerPageSE(this.this$0, LayerPageReport.access$600(this.this$0), this.this$0.parameterMap, isPageQuery(), this.paperPaintHeight);
      this.pageInfo = new PageInfo(LayerPageReport.LayerPageSE.access$500(this.se) * this.page_column_index_ft_list.size());
      this.last_row_index = -1;
      this.pageReport = null;
    }

    private void createPageReport()
    {
      this.pageReport = this.se.execute(paramInt, this.isPage);
    }

    public void release()
    {
      if (this.se != null)
      {
        this.se.release();
        this.se = null;
      }
      for (int i = 0; i < this.case4traversingList.size(); ++i)
        ((PageSet)this.case4traversingList.get(i)).release();
    }

    LayerPageSet(, PaperSetting paramPaperSetting, LayerPageReport.1 param1)
    {
      this(paramLayerPageReport, paramPaperSetting);
    }
  }
}